package uiLayer;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class MainMenuUI extends MenuUI{
	private Menu menu;
	private boolean exit;
	
	public static void main(String[] args){
		new MainMenuUI();
	}

	private MainMenuUI() {
		try {
			menu = new Menu("MainMenu", MainMenuUI.class);
			menu.add("Stock Menu", "startStockUI");
			menu.add("Exit", "writeEnd");
			menuStart();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private void menuStart() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		exit = false;
		while (!exit) {
			Method method = menu.run();
			if(method != null){
				method.invoke(this, null);
			}
		}
	}

	private void startStockUI() {
		new StockUI();
	}
	
	private void writeEnd() {
		System.out.println(" The System is shuting down ");
		exit = true;
	}
}
